<template>
	<view class="page page-fill">

		<view class="pending-wapper">
			<image :src="tempFace" class="pendding-face" mode="scaleToFill"></image>
		</view>

		<view class="notice">
			<view class="notice-words">
				* 请从相册中选择等比的图片~
			</view>
		</view>

		<view class="footer-opertor">
			<view class="opertor-words" @click="changePendingFace">
				重新选择
			</view>
			<view class="opertor-words" @click="upload">
				确认上传
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tempFace: ''
			}
		},
		onLoad(params) {
			this.tempFace = params.tempFilePath
			// this.tempFace = tempFilePath
		},
		methods: {
			// 重新选择
			changePendingFace() {
				uni.chooseImage({
					count: 1,
					sizeType: ["compressed"],
					success: (res) => {
						this.tempFace = res.tempFilePaths[0]
					}
				})
			},

			// 确认上传
			upload() {
				let tempglobalUser = this.$getGlobalUser()
				uni.showLoading({
					title: "上传中,请稍后",
					mask: true
				})
				
				uni.uploadFile({
					url: "",  //后台接口方法
					filePath: this.tempFace,
					name:"file", // 前后台参数统一
					header:{
						headerUserID: "",
						headerUserToken: ""
					},  // userId 和 token
					success: (res) => {
						console.log(res,'res');
						// 成功获取用户数据后，存储在本地中
					},
					complete() {
						uni.hideLoading()
					}
				})
				
				// 上传成功后返回
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("./meFace.scss");
</style>
